From 85b3f6d3729ec956b52b29c68fbbbd9eb46b1874 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 2 Dec 2017 01:29:36 +0100 Subject: [PATCH] image: Add gtk_image_new_from_texture() Docs and header knew about this function. There just was no implementation. --- gtk/gtkimage.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 82b9c43209..81710fa73b 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -468,7 +468,7 @@ gtk_image_new_from_resource (const gchar *resource_path) * pixbuf; you still need to unref it if you own references. * #GtkImage will add its own reference rather than adopting yours. * - * This is a helper for gtk_image_new_from_texture, and you can't + * This is a helper for gtk_image_new_from_texture(), and you can't * get back the exact pixbuf once this is called, only a texture. * * Note that this function just creates an #GtkImage from the pixbuf. The @@ -489,6 +489,33 @@ gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf) return GTK_WIDGET (image); } +/** + * gtk_image_new_from_texture: + * @pixbuf: (allow-none): a #GdkTexture, or %NULL + * + * Creates a new #GtkImage displaying @texture. + * The #GtkImage does not assume a reference to the + * texture; you still need to unref it if you own references. + * #GtkImage will add its own reference rather than adopting yours. + * + * Note that this function just creates an #GtkImage from the texture. The + * #GtkImage created will not react to state changes. Should you want that, + * you should use gtk_image_new_from_icon_name(). + * + * Returns: a new #GtkImage + **/ +GtkWidget* +gtk_image_new_from_texture (GdkTexture *texture) +{ + GtkImage *image; + + image = g_object_new (GTK_TYPE_IMAGE, NULL); + + gtk_image_set_from_texture (image, texture); + + return GTK_WIDGET (image); +} + /** * gtk_image_new_from_surface: * @surface: (allow-none): a #cairo_surface_t, or %NULL @@ -809,7 +836,7 @@ gtk_image_set_from_resource (GtkImage *image, * * See gtk_image_new_from_pixbuf() for details. * - * Note: This is a helper for gtk_image_new_from_texture, and you can't + * Note: This is a helper for gtk_image_set_from_texture(), and you can't * get back the exact pixbuf once this is called, only a texture. * **/ -- 2.30.2